package com.develop.web.in.request.json.field.serializer;

import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.jackson.JsonComponent;

import javax.money.MonetaryAmount;
import java.io.IOException;

@Slf4j
@JsonComponent
public class LoanUsage2Json extends StdSerializer<MonetaryAmount> {
    protected LoanUsage2Json() {
        super(MonetaryAmount.class);
    }

    @Override
    public void serialize(MonetaryAmount amount, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException {
        //jsonGenerator.writeNumber(money.getAmount());
        log.info(amount.toString());
        jsonGenerator.writeString(amount.toString());
    }
}
